home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / print / hpgl2ps.zip / PLOTPS.C < prev    next >
C/C++ Source or Header  |  1989-08-08  |  1KB  |  67 lines

  1. /* plotps.c */
  2. #include "defn.h"
  3.  
  4. #define MAXDRAWPOINTS    100
  5.  
  6. plotps(type)
  7. char   *type;
  8. {
  9.     if (type == MOVE || type == RMOVE)
  10.     {
  11.     while (SIGNED_NUMERIC)
  12.     {
  13.         if (type == MOVE)
  14.         {
  15.         end_draw();
  16.         absX = lastXmove = getval() * XSCALE + offX;
  17.         absY = lastYmove = getval() * YSCALE + offY;
  18.         } else
  19.         if (type == RMOVE)
  20.         {
  21.         end_draw();
  22.         lastXmove = absX += getval() * XSCALE ;
  23.         lastYmove = absY += getval() * YSCALE ;
  24.         }
  25.     }
  26.     }
  27.     else            /* Must be a DRAW or RDRAW */
  28.     {
  29.     while (SIGNED_NUMERIC)
  30.     {
  31.         if (dcount++ >= MAXDRAWPOINTS)
  32.         {
  33.         end_draw();
  34.         printf("newpath\n");
  35.         printf("  %g %g %s\n", absX, absY, MOVE);
  36.         DRAW_FLAG = 1;
  37.         /* fprintf(stderr, "Warning exceeded %d draw points\n",
  38.               MAXDRAWPOINTS); */
  39.         }
  40.         xval = getval() * XSCALE;
  41.         yval = getval() * YSCALE;
  42.         if (!DRAW_FLAG)
  43.         {
  44.         printf("newpath\n");
  45.         printf("  %g %g %s\n", absX, absY, MOVE);
  46.         DRAW_FLAG = 1;
  47.         }
  48.         if (type == RDRAW)
  49.         {
  50.         absX += xval;
  51.         absY += yval;
  52.         printf("  %g %g %s\n", xval, yval, RDRAW);
  53.         } else
  54.         if (type == DRAW)
  55.         {
  56.         absX = xval + offX;
  57.         absY = yval + offY;
  58.         printf("  %g %g %s\n", absX, absY, DRAW);
  59.         } else
  60.         {
  61.         fprintf(stderr, "Error: expecting draw command not %s\n", type);
  62.         exit(1);
  63.         }
  64.     }
  65.     }
  66. }
  67.